# -*- coding: UTF-8 -*-
import pytest
import sqlite3

@pytest.fixture(scope='session')
def connects():
    conn = sqlite3.connect('funds.db')
    print('连接成功')
    yield conn
    conn.close()
    print('连接关闭')

def test_conn(connects):
    cur = connects.cursor()
    data = cur.execute('select count(*) from fund')
    value = data.fetchone()
    result = value[0]
    assert result == 11201

class Test_conn():

    def test2_conn(self,connects):
        cur = connects.cursor()
        data = cur.execute('select * from fund')
        results = data.fetchall()
        result = len(results)
        assert result == 11201

if __name__ == '__main__':
    pytest.main(['-s','yangsy.py'])
